﻿<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="DoAnPhatTrienPhanMem.Controllers" %>
<%@ Import Namespace="DoAnPhatTrienPhanMem.Models" %>
<%@ Import Namespace="DoAnPhatTrienPhanMem.Constants" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="/Scripts/CommonFunction.js" type="text/javascript"></script>
    <script src="/Scripts/Constant.js" type="text/javascript"></script>
    <link href="/Content/MainStyle.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .rowtpl
        {
            width: auto;
            height: 120px;
            border-bottom-width: 1px;
            border-bottom-color: Black;
            border-bottom-style: solid;
            padding: 0px 0px 0px 10px;
        }
        .rowtpl a
        {
            color: Blue;
            font: 14px;
        }
    </style>
    <script runat="server">
        private void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var user = "";
                if (Session[Constants.SessionName.UserName] != null) user = Session[Constants.SessionName.UserName].ToString();
                var AccountCtrl = new AccountController();
                Ext.Net.MenuItem node;
                if (AccountCtrl.CheckRole(user, "VienKhoaHoc", "AddOrEdit", ""))
                {
                    node = new Ext.Net.MenuItem { Text = "Thêm viện khoa học" };
                    node.Listeners.Click.Handler = "CommonFunction.loadPage('VienKhoaHoc','AddOrEdit','');";
                    MainMenu.Menu.Add(node);
                }

                if (!String.IsNullOrEmpty(user))
                {
                    frmLogin.Hidden = true;
                    btnLogin.Hidden = true;
                    UserID.Text = user;
                    //UserID.NavigateUrl = "#";
                    UserID.Hidden = false;
                    afterLogin.Hidden = false;
                    var MaCB = AccountCtrl.GetByUserName(user).MaCB;
                    if (MaCB != null)
                    {
                        var CanBoCtrl = new CanBoController();
                        var IDcanbo = CanBoCtrl.GetSoYeuCanBoByMaCB(MaCB.ToString()).ID;
                        UserID.Listeners.Click.Handler = "CommonFunction.loadPage('CanBo','Details',{ID: '" + IDcanbo + "'});";
                    }
                }
            }
        }
    </script>
    <script type="text/javascript">
        function frmSubmit() {
            window.frmLogin.getForm().submit({
                waitMsg: 'Đang kiểm tra...',
                waitTitle: 'Xác thực quyền đăng nhập',
                clientValidation: true,
                success: CommonFunction.refreshFrame,
                failure: CommonMessenger.failureHandler
            });
        }
    </script>
</head>
<body id="bd" class="fs3">
    <ext:ResourceManager runat="server" Locale="vi-VN" CleanResourceUrl="false" />
    <ext:Store runat="server" ID="storeList" AutoLoad="true">
        <Proxy>
            <ext:HttpProxy Url="/VienKhoaHoc/GetAll" />
        </Proxy>
        <Reader>
            <ext:JsonReader Root="data">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="MaVien" />
                    <ext:RecordField Name="TenVien" />
                    <ext:RecordField Name="DiaChi" />
                    <ext:RecordField Name="NhiemVu" />
                    <ext:RecordField Name="GhiChu" />
                    <ext:RecordField Name="SLcanbo" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <div id="ja-wrapper">
        <div id="ja-container" class="wrap clearfix">
            <div class="main">
                <div class="inner clearfix">
                    <div id="ja-mainbody">
                        <ext:DataView ID="DataView1" runat="server" StoreID="storeList" ItemSelector="rowtpl">
                            <Template ID="Template1" runat="server">
                                <Html>
                                    <tpl for=".">
                                        <div class="rowtpl">
                                            <div><a href="#" onclick="CommonFunction.loadPage('PhongKhoaHoc','Index',{IDvien: '{ID}'});"><b>{TenVien}</b></a></div>
                                            <div><b>Địa chỉ</b>: {DiaChi} </div>
                                            <div><b>Nhiệm vụ</b>: {NhiemVu}</div>
                                            <div><b>Số lượng cán bộ</b>: {SLcanbo}</div>
                                        </div>
                                    </tpl>
                                </Html>
                            </Template>
                        </ext:DataView>
                    </div>
                    <div id="ja-colwrap">
                        <div class="ja-innerpad">
                            <div style="padding: 10px;">
                                <ext:CompositeField runat="server" ID="afterLogin" Hidden="true" LabelWidth="20">
                                    <Items>
                                        <ext:LinkButton runat="server" ID="UserID" />
                                        <ext:LinkButton ID="LinkButton1" runat="server" Text="(Đăng xuất)" NavigateUrl="/Account/Logout" />
                                    </Items>
                                </ext:CompositeField>
                                <ext:FormPanel runat="server" ID="frmLogin" Url="/Account/Login" Border="false" BodyBorder="false"
                                    Layout="FormLayout" AutoHeight="true" AutoWidth="true" LabelWidth="70">
                                    <Items>
                                        <ext:TextField runat="server" ID="Username" FieldLabel="Tài khoản" LabelWidth="50"
                                            AllowBlank="false" />
                                    </Items>
                                </ext:FormPanel>
                            </div>
                            <div style="padding-left: 155px;">
                                <ext:Button ID="btnLogin" runat="server" Text="Đăng nhập">
                                    <Listeners>
                                        <Click Fn="frmSubmit" />
                                    </Listeners>
                                </ext:Button>
                            </div>
                            <div id="Mod1" class="moduletable_menu">
                                <div class="ja-box-ct">
                                    <ul class="menu">
                                        <ext:MenuPanel runat="server" ID="MainMenu" Header="false" Border="false" />
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
